home *** CD-ROM | disk | FTP | other *** search
- Path: yrkpa.kias.com!not-for-mail
- From: glynis@yrkpa.kias.com (John Flinchbaugh)
- Newsgroups: comp.lang.c
- Subject: mixing enums and integers
- Date: 5 Jan 1996 02:15:32 -0500
- Organization: Keystone Information Access Systems
- Message-ID: <4cij6k$dvb@yrkpa.kias.com>
- NNTP-Posting-Host: yrkpa.kias.com
- X-Newsreader: NewsWerthy 2.02 (unregistered)
-
- the faq states that mixing enums and ints is legal, but poor style.
-
- i'd like to use enums to organize my constants, like this:
-
- enum DIRECT {UP=72,LEFT=75,RIGHT=77,DOWN=80};
- int key;
- getch(); /* dos code to get the second byte of 2-byte */
- key=getch(); /* key codes from keyboard */
- if (key==UP) printf("up");
- ...
-
- now this should work, but it's poor style, right?
- would casting it be more proper:
-
- if ((enum DIRECT) key==up) ...
-
- also, can you typedef enums? if so, how?
-
- --
- _____________________}John Flinchbaugh{______________________
- | -> glynis@yrkpa.kias.com <- jmflinch@cs.millersv.edu |
- | glynis@bitbytes.com jmf89784@marauder.millersv.edu |
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-